#include <algorithm>
#include <iostream>
#include <vector>

class Point 
{
public:
	double x, y;

	Point(double x_, double y_)
	{
		x = x_;
		y = y_;
	}
};

bool compareToXY(Point p1, Point p2) 
{
	if (p1.x < p2.x)
		return true;
	if (p1.x > p2.x)
		return false;
	return (p1.y < p2.y);
}

bool compareToYX(Point p1, Point p2) 
{
	if (p1.y < p2.y)
		return true;
	if (p1.y > p2.y)
		return false;
	return (p1.x < p2.x);
}

std::ostream& operator<<(std::ostream &os, const Point &p)
{
	os << p.x << " " << p.y << "\n";
	return os;
}

int main() 
{
	using std::cin;
	using std::cout;

	int n;
	cin >> n;

	std::vector<Point> points;
	double x, y;
	for (int i = 0; i < n; i++) 
	{
		cin >> x >> y;
		points.push_back(Point(x, y));
	}

	std::sort(points.begin(), points.end(), compareToXY);

	int m;
	cin >> m;
	double x1, y1, x2, y2;

	for (int i = 0; i < m; i++) 
	{
		cin >> x1 >> y1 >> x2 >> y2;

		size_t num = 0;
		while (num < points.size() && x1 > points[num].x) 
		{
			num++;
		}

		std::vector<Point> temp;
		while (num < points.size() && x2 >= points[num].x) 
		{
			temp.push_back(points[num]);
			num++;
		}

		std::sort(temp.begin(), temp.end(), compareToYX);
		
		num = 0;
		while (num < temp.size() && y1 > temp[num].y)
		{
			num++;
		}

		int ans = 0;
		while (num + ans < temp.size() && y2 >= temp[num + ans].y)
		{
			ans++;
		}

		cout << ans << "\n";
		for (int i = 0; i < ans; i++) 
		{
			cout << temp[num + i];
		}
	}
}